#include <iostream>
#include <map>
#include <string>

using namespace std;
map<string, string> enToChDictionary = {
    {"hello", "你好"},
    {"world", "世界"},
    {"apple", "苹果"},
    {"banana", "香蕉"},
    {"computer", "电脑"},
    {"cat", "猫"},
    {"dog", "狗"},
    {"book", "书"},
    {"table", "桌子"},
    {"phone", "电话"}
};
map<string, string> chToEnDictionary = {
    {"你好", "hello"},
    {"世界", "world"},
    {"苹果", "apple"},
    {"香蕉", "banana"},
    {"电脑", "computer"},
    {"猫", "cat"},
    {"狗", "dog"},
    {"书", "book"},
    {"桌子", "table"},
    {"电话", "phone"}
};

// 根据输入内容和词典查找对应的翻译
string findTranslation(string& input, map<string, string>& dictionary) {
    auto it = dictionary.find(input);
    if (it != dictionary.end()) {
        string value = dictionary[input];
        return value;
    }
    else {
        return "未找到对应的翻译。";
    }
}

int main()
{
    cout << "请输入单词或中文： " << endl;
    string str;
    getline(cin, str);

    bool isEn = false;
    for (int i = 0; i < str.length(); i++) {
        if ('A' <= str[i] && str[i] <= 'z') {
            isEn = true;
            break; 
        }
    }

    if (isEn) {
        cout << "对应的中文翻译是：" << findTranslation(str, enToChDictionary) << endl;
    }
    else {
        // 输入的是中文，查询汉译英词典
        cout << "对应的英文翻译是：" << findTranslation(str, chToEnDictionary) << endl;
    }

    return 0;
}
